#include "PhotoShop_Algorithm.h"


using namespace cv;
using namespace std;


void test_ColorTrans(std::string& save_path, const cv::Mat& image)
{
	MEASURE_TIME({
		for (size_t i = 0; i < 7; i++) {
			Mat image2 = PhotoShop::ColorTransPtr(image, i + 1);
			//cv::imwrite(save_path + "ColorTransPtr_op" + to_string(i) + ".png", image2);
		}
		}, "ColorTransPtr operation");

	MEASURE_TIME({
		for (size_t i = 0; i < 7; i++) {
			Mat image2 = PhotoShop::ColorTrans(image, i + 1);
			//cv::imwrite(save_path + "ColorTrans_op" + to_string(i) + ".png", image2);
		}
		}, "ColorTrans operation");
}


void test_MinMax(std::string& save_path, const cv::Mat& image, const cv::Mat& image2)
{
	MEASURE_TIME({
		Mat result = PhotoShop::MinMaxPtr(image, image2, 0);
		cv::imwrite(save_path + "MinMaxPtr.png", result);
		}, "MinMaxPtr operations");

	MEASURE_TIME({
		Mat result = PhotoShop::MinMax(image, image2, 0);
		cv::imwrite(save_path + "MinMax.png", result);
		}, "MinMax operation");
}


void test_DiamondEmboss(std::string& save_path, const cv::Mat& image)
{
	MEASURE_TIME({
	Mat result = PhotoShop::DiamondEmbossPtr(image);
	cv::imwrite(save_path + "DiamondEmbossPtr.png", result);
		}, "DiamondEmbossPtr operations");

	MEASURE_TIME({
		Mat result = PhotoShop::DiamondEmboss(image);
		cv::imwrite(save_path + "DiamondEmboss.png", result);
		}, "DiamondEmboss operation");
}


void test_GaussDistributionMask(std::string& save_path, const cv::Mat& image)
{
	MEASURE_TIME({
	Mat result = PhotoShop::GaussDistributionMaskPtr(image);
	cv::imwrite(save_path + "GaussDistributionMaskPtr.png", result);
		}, "GaussDistributionMaskPtr operations");

	MEASURE_TIME({
		Mat result = PhotoShop::GaussDistributionMask(image);
		cv::imwrite(save_path + "GaussDistributionMask.png", result);
		}, "GaussDistributionMask operation");
}


void test_Bright(std::string& save_path, const cv::Mat& image)
{
	MEASURE_TIME({
	Mat result = PhotoShop::BrightPtr(image, 50);
	cv::imwrite(save_path + "BrightPtr.png", result);
		}, "BrightPtr operations");

	MEASURE_TIME({
		Mat result = PhotoShop::Bright(image, 50);
		cv::imwrite(save_path + "Bright.png", result);
		}, "Bright operation");
}


void test_PaperCutArtFilter(std::string& save_path, const cv::Mat& image)
{
	MEASURE_TIME({
		Mat result = PhotoShop::PaperCutArtFilter(image);
		cv::imwrite(save_path + "PaperCutArtFilter.png", result);
		}, "PaperCutArtFilter operation");
}


void test_Translate(std::string& save_path, const cv::Mat& image)
{
	MEASURE_TIME({
	Mat result = PhotoShop::TranslatePtr(image, 50, -80, 1);
	cv::imwrite(save_path + "TranslatePtr.png", result);
		}, "TranslatePtr operations");

	MEASURE_TIME({
		Mat result = PhotoShop::Translate(image, 50, -80, 1);
		cv::imwrite(save_path + "Translate.png", result);
		}, "Translate operation");
}


void test_Sketch(std::string& save_path, const cv::Mat& image)
{
	MEASURE_TIME({
	Mat result = PhotoShop::SketchPtr(image);
	cv::imwrite(save_path + "SketchPtr.png", result);
		}, "SketchPtr operations");

	MEASURE_TIME({
	Mat result = PhotoShop::Sketch(image);
	cv::imwrite(save_path + "Sketch.png", result);
		}, "Sketch operation");
}


void test_Harmonic(std::string& save_path, const cv::Mat& image)
{
	MEASURE_TIME({
	Mat result = PhotoShop::HarmonicPtr(image);
	cv::imwrite(save_path + "HarmonicPtr.png", result);
		}, "HarmonicPtr operations");

	MEASURE_TIME({
	Mat result = PhotoShop::Harmonic(image);
	cv::imwrite(save_path + "Harmonic.png", result);
		}, "Harmonic operation");
}


void test_HighPass(std::string& save_path, const cv::Mat& image)
{
	MEASURE_TIME({
	Mat result = PhotoShop::HighPassPtr(image);
	cv::imwrite(save_path + "HighPassPtr.png", result);
		}, "HighPassPtr operations");

	MEASURE_TIME({
	Mat result = PhotoShop::HighPass(image);
	cv::imwrite(save_path + "HighPass.png", result);
		}, "HighPass operation");
}


void test_Masic(std::string& save_path, const cv::Mat& image)
{
	MEASURE_TIME({
	Mat result = PhotoShop::MasicPtr(image, 5);
	cv::imwrite(save_path + "MasicPtr.png", result);
		}, "MasicPtr operations");

	MEASURE_TIME({
	Mat result = PhotoShop::Masic(image, 5);
	cv::imwrite(save_path + "Masic.png", result);
		}, "Masic operation");
}


void test_Invert(std::string& save_path, const cv::Mat& image)
{
	MEASURE_TIME({
	Mat result = PhotoShop::InvertPtr(image);
	cv::imwrite(save_path + "InvertPtr.png", result);
		}, "InvertPtr operations");

	MEASURE_TIME({
	Mat result = PhotoShop::Invert(image);
	cv::imwrite(save_path + "Invert.png", result);
		}, "Invert operation");
}


void test_Equalizer(std::string& save_path, const cv::Mat& image)
{
	MEASURE_TIME({
	Mat result = PhotoShop::EqualizerPtr(image);
	cv::imwrite(save_path + "EqualizerPtr.png", result);
		}, "EqualizerPtr operations");

	MEASURE_TIME({
	Mat result = PhotoShop::Equalizer(image);
	cv::imwrite(save_path + "Equalizer.png", result);
		}, "Equalizer operation");
}


void test_Equalize(std::string& save_path, const cv::Mat& image)
{
	MEASURE_TIME({
	Mat result = PhotoShop::EqualizePtr(image);
	cv::imwrite(save_path + "EqualizePtr.png", result);
		}, "EqualizePtr operations");

	MEASURE_TIME({
	Mat result = PhotoShop::Equalize(image);
	cv::imwrite(save_path + "Equalize.png", result);
		}, "Equalize operation");
}


void test_LaplaceSharp(std::string& save_path, const cv::Mat& image)
{
	MEASURE_TIME({
	Mat result = PhotoShop::LaplaceSharpPtr(image);
	cv::imwrite(save_path + "LaplaceSharpPtr.png", result);
		}, "LaplaceSharpPtr operations");

	MEASURE_TIME({
	Mat result = PhotoShop::LaplaceSharp(image);
	cv::imwrite(save_path + "LaplaceSharp.png", result);
		}, "LaplaceSharp operation");
}


void test_Emboss(std::string& save_path, const cv::Mat& image)
{
	MEASURE_TIME({
	Mat result = PhotoShop::EmbossPtr(image);
	cv::imwrite(save_path + "EmbossPtr.png", result);
		}, "EmbossPtr operations");

	MEASURE_TIME({
	Mat result = PhotoShop::Emboss(image);
	cv::imwrite(save_path + "Emboss.png", result);
		}, "Emboss operation");
}


void test_Contrast(std::string& save_path, const cv::Mat& image)
{
	MEASURE_TIME({
	Mat result = PhotoShop::ContrastPtr(image, 50);
	cv::imwrite(save_path + "ContrastPtr.png", result);
		}, "ContrastPtr operations");

	MEASURE_TIME({
	Mat result = PhotoShop::Contrast(image, 50);
	cv::imwrite(save_path + "Contrast.png", result);
		}, "Contrast operation");
}


void test_ColorBalance(std::string& save_path, const cv::Mat& image)
{
	MEASURE_TIME({
		Mat result = PhotoShop::ColorBalancePtr(image, 50, 60, 80);
		cv::imwrite(save_path + "ColorBalancePtr.png", result);
		}, "ColorBalancePtr operations");

	MEASURE_TIME({
		Mat result = PhotoShop::ColorBalance(image, 50, 60, 80);
		cv::imwrite(save_path + "ColorBalance.png", result);
		}, "ColorBalance operation");
}


void test_TemplateBlur(std::string& save_path, const cv::Mat& image)
{
	MEASURE_TIME({
		Mat result = PhotoShop::TemplateBlurPtr(image);
		cv::imwrite(save_path + "TemplateBlurPtr.png", result);
		}, "TemplateBlurPtr operations");

	MEASURE_TIME({
		Mat result = PhotoShop::TemplateBlur(image);
		cv::imwrite(save_path + "TemplateBlur.png", result);
		}, "TemplateBlur operation");
}


void test_MedianFilter(std::string& save_path, const cv::Mat& image)
{
	MEASURE_TIME({
		Mat result = PhotoShop::MedianFilterPtr(image);
		cv::imwrite(save_path + "MedianFilterPtr.png", result);
		}, "MedianFilterPtr operations");

	MEASURE_TIME({
		Mat result = PhotoShop::MedianFilter(image);
		cv::imwrite(save_path + "MedianFilter.png", result);
		}, "MedianFilter operation");
}


void test_WaveFilter(std::string& save_path, const cv::Mat& image)
{
	MEASURE_TIME({
		Mat result = PhotoShop::WaveFilter(image);
		cv::imwrite(save_path + "WaveFilter.png", result);
		}, "WaveFilter operation");
}




int main() {
	string img_path = "E:/cython/image-processing-algorithm/test_image_effect/src.jpg";
	string img_path3 = "E:/cython/image-processing-algorithm/test_image_effect/desktop_src.png";
	string img_path2 = "E:/cython/image-processing-algorithm/test_image_effect/ColorTransPtr_op0.png";
	string save_path = "E:/cython/image-processing-algorithm/test_image_effect/";
	Mat image = cv::imread(img_path);
	if (image.empty())
	{
		cout << "imag file: " << img_path << " not found!\n";
		return -1;
	}
	Mat image2 = cv::imread(img_path2);
	if (image2.empty())
	{
		cout << "imag file: " << img_path2 << " not found!\n";
		return -1;
	}
	Mat image3 = cv::imread(img_path3);
	if (image3.empty())
	{
		cout << "imag file: " << img_path3 << " not found!\n";
		return -1;
	}

	test_ColorTrans(save_path, image);
	test_DiamondEmboss(save_path, image);
	test_Translate(save_path, image);
	test_Sketch(save_path, image);
	test_Harmonic(save_path, image);
	test_HighPass(save_path, image);
	test_Masic(save_path, image);
	test_Equalizer(save_path, image);
	test_Equalize(save_path, image);
	test_LaplaceSharp(save_path, image);
	test_Contrast(save_path, image);
	test_ColorBalance(save_path, image);
	test_TemplateBlur(save_path, image);
	test_MedianFilter(save_path, image);
	test_Emboss(save_path, image);
	test_Invert(save_path, image);
	test_WaveFilter(save_path, image);
	test_PaperCutArtFilter(save_path, image);
	test_Bright(save_path, image);
	test_GaussDistributionMask(save_path, image);
	test_MinMax(save_path, image, image2);
	cv::imshow("ColorTransPt", image);
	cv::waitKey(0);
	cv::destroyAllWindows();
	return 0;
}